package com.neusoft.ysu.populationmanagement.mapper;

import com.neusoft.ysu.populationmanagement.entity.Population;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.neusoft.ysu.populationmanagement.vo.TypeCount;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author 作者：赵子鉴
 * @since 2024-06-18
 */
@Mapper
public interface PopulationMapper extends BaseMapper<Population> {
    @Select("select * from population where idnum=#{idnum} AND is_delete=0 ")
    List<Population> selectByIdNum(String idnum);

    @Select("select pop_type_id , count(id) popCount from population where address like CONCAT('%', #{area}, '%') AND is_delete=0 GROUP BY pop_type_id")
    List<TypeCount> selectByAddress(@Param("area") String area);

//    @Insert({
//            "<script>",
//            "INSERT INTO population (name, idnum, birthday,gender_id,nation_id,blood_id,edu_id,marry_id,disability_id,military_id," +
//                    "pop_type_id,address,create_time,update_time,is_delete)",
//            "VALUES "+
//            " <foreach collection='list' item='pop' separator=','>"+
//            " (      #{pop.name}," +
//                    "#{pop.name}, " +
//                    "#{pop.idnum}, " +
//                    "#{pop.birthday}," +
//                    "#{pop.genderId}," +
//                    "#{pop.nationId}," +
//                    "#{pop.bloodId}," +
//                    "#{pop.eduId}," +
//                    "#{pop.marryId}," +
//                    "#{pop.disabilityId}," +
//                    "#{pop.militaryId}," +
//                    "#{pop.popTypeId}," +
//                    "#{pop.address}," +
//                    "#{pop.createTime}," +
//                    "#{pop.updateTime}," +
//                    "#{pop.isDelete})",
//            "</foreach>",
//            "</script>"
//    })
    int insertPopList(@Param("list") List<Population> populationList);
}
